package org.acghub.mtdb.common.type.impl;

import org.acghub.mtdb.common.Visitor;
import org.acghub.mtdb.common.type.TypeBasePrimitives;
import org.acghub.mtdb.util.StringUtil;

import java.util.function.Function;

/**
 * @author zhouhe
 */
public class TypeFloat extends TypeBasePrimitives {
    public TypeFloat() {
        super("float");
    }

    @Override
    public void accept(Visitor visitor) {
        visitor.visit(this);
    }

    @Override
    protected Function<String, Object> checkDefaultValueFunc() {
        return Float::parseFloat;
    }

    @Override
    public String getDefaultValue() {
        return ".0F";
    }

    @Override
    protected String dealDefaultValue(String value) {
        return StringUtil.checkValueSuffix(value, "F");
    }
}
